﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;

namespace AnimalWars2
{
    public class GameMap : GameScreen
    {
        protected Texture2D m_MapBackgroundTexture;

        protected SoundEffect m_MapSoundEffect;
        protected SoundEffectInstance m_MapSoundEffectInstance;

        protected MapPlayer m_MapPlayer;

        public GameMap(Game GameRef)
            : base(GameRef)
        {
            m_MapPlayer = new MapPlayer(this);
        }

        public void GoToTable()
        {
            m_Game.ChangeScreen(m_Game.m_GameTable);
        }

        public override void LoadContent()
        {
            m_MapBackgroundTexture = m_Game.Content.Load<Texture2D>(Constants.MAP_BACKGROUND_ASSET_NAME);            

            m_MapSoundEffect = m_Game.Content.Load<SoundEffect>(Constants.GAME_MAP_SOUND_ASSET_NAME);
            m_MapSoundEffectInstance = m_MapSoundEffect.CreateInstance();
            m_MapSoundEffectInstance.IsLooped = true;

            if (Constants.PLAY_SOUND)
            {
                m_MapSoundEffectInstance.Play();
            }

            m_MapPlayer.LoadContent();
        }

        public override void UnloadContent()
        {
            
        }

        public override void Update(GameTime gameTime)
        {
            m_MapPlayer.Update(gameTime);
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(m_MapBackgroundTexture, new Vector2(0, 0), Color.White);

            m_MapPlayer.Draw(gameTime, spriteBatch);
        }
    }
}
